home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 10
/
FM Towns Free Software Collection 10.iso
/
ms_dos
/
tool
/
txf
/
src
/
txflog.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-05-05
|
2KB
|
97 lines
/*====================================================================
*
* TXF matchstr module
*
*====================================================================
* copyright(C) 1992-1994 T.Nakatani
*====================================================================
*/
#include "txf.h"
int matchstr(char *form, char far *txtptr)
{
char far *logtmp;
char *strtmp;
int i, trueflg = 0, count = 0;
logtmp = txtptr;
strtmp = form;
while ((*strtmp != NUL) && (*logtmp != 0x0a)) {
trueflg = FALSE;
switch (*strtmp) {
case '%':
if (isdigit(*logtmp) || (*logtmp == ' ')) {
trueflg = TRUE;
}
break;
case '*':
if (isalpha(*logtmp)) {
trueflg = TRUE;
}
break;
case '&':
if (isalpha(*logtmp) || isdigit(*logtmp)) {
trueflg = TRUE;
}
break;
case '_':
if (*logtmp == ' ') {
trueflg = TRUE;
}
break;
case '$':
trueflg = TRUE;
break;
case 0x27:
strtmp++;
if (*logtmp == *strtmp) {
trueflg = TRUE;
}
break;
case '^':
strtmp++;
count = ((*strtmp) - ('0'));
strtmp++;
while (trueflg != TRUE) {
for (i = 0; i < count; i++) {
if (*(logtmp + i) != *(strtmp + i)) {
break;
}
}
if (i != count) {
logtmp++;
if (*logtmp == 0x0a) {
break;
}
}
else {
trueflg = TRUE;
}
}
break;
default:
if (islower(*strtmp)) {
if (tolower(*logtmp) == *strtmp) {
trueflg = TRUE;
}
}
else {
if (*logtmp == *strtmp) {
trueflg = TRUE;
}
}
}
/* printf("matchstr:%c,%c:", *strtmp, *logtmp); */
if (trueflg != TRUE) {
/* puts("NG!"); */
return (FALSE);
}
/* puts("GOOD!"); */
strtmp++;
logtmp++;
}
return (TRUE);
}